home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
FM Towns: Free Software Collection 6
/
FM Towns Free Software Collection 6.iso
/
t_os
/
book
/
src
/
debug.c
< prev
next >
Wrap
C/C++ Source or Header
|
1993-07-08
|
3KB
|
112 lines
#include <stdio.h>
#include <stdlib.h>
#include <stdarg.h>
#include <string.h>
#include <ctype.h>
#include <egb.h>
#include <mos.h>
#include <fmc.h>
#include "book.h"
#include "menu_evt.h"
extern int _mwgetbp(), _mwstack_limit;
void fprt(char *file, char *form, ...)
{
FILE *fp;
va_list arg;
if ((fp = fopen(file, "a+")) != NULL)
{
fseek(fp, 0L, SEEK_END);
va_start(arg, form);
vfprintf(fp, form, arg);
va_end(arg);
fclose(fp);
}
}
void prt(int x,int y, char *form, ...)
{
va_list arg;
char tmp[256];
int wpage = writepage;
va_start(arg, form);
vsprintf(tmp, form, arg);
writepage = PAGE1;
wrt(tmp, x,y, 15,1, 16);
va_end(arg);
writepage = wpage;
}
void stack_avail(char *msg)
{
int stack = _mwgetbp() -_mwstack_limit;
const char *path = "result";
if (msg != NULL)
fprt((char *)path, msg);
fprt((char *)path, "stack %d(%08Xh) bytes\n", stack,stack);
}
char *cnv_evt2str(mevt_t evt)
{
static char buf[16];
switch (evt)
{
case MEv_NULL: return "MEv_NULL";
case MEv_EXIT: return "MEv_EXIT";
case MEv_SELECT: return "MEv_SELECT";
case MEv_CANCEL: return "MEv_CANCEL";
case MEv_SND: return "MEv_SND";
case MEv_FS: return "MEv_FS";
case MEv_vDOWN: return "MEv_vDOWN";
case MEv_vUP: return "MEv_vUP";
case MEv_GOTO_TOP:return "MEv_GOTO_TOP";
case MEv_GOTO_BTM:return "MEv_GOTO_BTM";
case MEv_sDOWN: return "MEv_sDOWN";
case MEv_sUP: return "MEv_sUP";
case MEv_mDOWN: return "MEv_mDOWN";
case MEv_mUP: return "MEv_mUP";
case MEv_hDOWN: return "MEv_hDOWN";
case MEv_hUP: return "MEv_hUP";
case MEv_uDOWN: return "MEv_uDOWN";
case MEv_uUP: return "MEv_uUP";
case MEv_FORM: return "MEv_FORM";
case MEv_FULLPATH:return "MEv_FULLPATH";
case MEv_SEARCH: return "MEv_SEARCH";
case MEv_DISPCR: return "MEv_DISPCR";
case MEv_DOSCMD: return "MEv_DOSCMD";
case MEv_WIDTH: return "MEv_WIDTH";
case MEv_MOVE: return "MEv_MOVE";
case MEv_CURMOVE: return "MEv_CURMOVE";
case MEv_rSEARCH: return "MEv_rSEARCH";
case MEv_fSEARCH: return "MEv_fSEARCH";
case MEv_ErSEARCH:return "MEv_ErSEARCH";
case MEv_FfSEARCH:return "MEv_FfSEARCH";
case MEv_sSAME: return "MEv_sSAME";
case MEv_sDIFF: return "MEv_sDIFF";
case MEv_UPPERDIR:return "MEv_UPPERDIR";
case MEv_ROOTDIR: return "MEv_ROOTDIR";
case MEv_UPDIR: return "MEv_UPDIR";
case MEv_SORTMD: return "MEv_SORTMD";
case MEv_DISPMD: return "MEv_DISPMD";
case MEv_REPEAT: return "MEv_REPEAT";
case MEv_DUMMY: return "MEv_DUMMY";
default:
sprintf(buf, "event %2d", evt);
return buf;
}
}